# -*-  coding:utf-8 -*- 
# Author : lihongliang
"""
函数进阶
写函数，返回一个扑克牌列表，里面有52项目，每一项都是一个元组
如：[("红心"，2), ("草花", 2), ...("黑桃"，1)]






# 写函数，传入一个参数n, 返回N的阶乘

def cards():
    num = []
    for i in range(2,11):
        num.append(i)
    num.extend(["J","Q","K","A"])
    type = ["红心","草花","方块","黑桃"]
    result = []
    for i in num :
        for j in type:
            result.append((j,i))
    return result

print(cards())

# 写函数, 传入n个数，返回字典
# {"max": 最大值, 'min': 最小值}
# 如
# min_max(2, 5, 7, 10, 4, 1, 3)
# 返回：{"max": 10, "min": 1}

def  max_min(*args):
    num_max = args[0]
    num_min = args[0]
    for i in args:
        if i > num_max:
            num_max = i
        else:
            num_min = i
    return {"max":num_max, "min":num_min}

res = max_min(2,4,6,9,-18,55)
print(res)


写函数，专门计算图形面积
其中嵌套函数，计算图的面积，正方形的面积和长方形的面积
调用函数area（"图形"，圆半径）返回圆的面积
调用函数area（"正方形"，边长）返回正方形的面积
调用函数area（"长方形"，长, 宽）返回正方形的面积

def area():
    def 计算长方形面积():
        pass
    def 计算正方形面积():
        pass
    def 计算圆形面积():
        pass

import math
def  area(name,*args):
    def areas_rectangle(x,y):
        return ("长方形面积为：", x*y)

    def areas_square(x):
        return ("正方形面积为：",x**2)

    def areas_round(r):
        return ("圆形面积为：",math.pi*r*r)

    if name == "圆形":
        return areas_round(*args)
    elif name == "长方形":
        return  areas_rectangle(*args)
    elif name == '正方形':
        return  areas_square(*args)

tuxing = input("请输入要计算那种面积（圆形，长方形，正方形）：")
if tuxing == '长方形':
    a = int(input("请输入长方形的长："))
    b = int(input("请输入长方形的宽："))
    print(area("长方形",a,b))
elif tuxing == "正方形":
    a = int(input("请输入正方形边长;"))
    print(area("正方形",a))
elif  tuxing == "圆形":
    a = int(input("请输入圆形的半径;"))
    print(area("圆形",a))
else:
    print("输入不正确")

"""

# 传入一个数N，返回N的阶乘


def cal(n):
    result = 1
    for i in range(n,0,-1):
        result = result*i
    return result
print(cal(6))


